package com.juc.threadPoolExecutor.threadPoolExecutor18;

import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class GetActiveCount_Test1 {
    /**
     * getPoolSize() 获取当前线程池中有多少个线程，这些线程数
     * 包括正在执行任务的线程，也包括正在休眠的线程
     * 
     * getActiveCount()获得正在执行任务的线程数
     * 
     * 
     */
	public static void main(String[] args) throws InterruptedException {
		MyThreadA a = new MyThreadA();
		SynchronousQueue<Runnable> queue = new SynchronousQueue<>();
		ThreadPoolExecutor pool = new ThreadPoolExecutor(2, 5, 5, TimeUnit.SECONDS, queue);
		pool.execute(a);
		pool.execute(a);
		pool.execute(a);
		System.out.println(pool.getActiveCount() + "  " + pool.getPoolSize());
		Thread.sleep(7000);
		System.out.println(pool.getActiveCount() + "  " + pool.getPoolSize());

	}
}
